<template>
  <div class="mui-numbox" data-numbox-min="1">
    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
    <input class="mui-input-numbox" type="number" @change="postnum" ref="numbox" />
    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
  </div>
</template>
<style lang="less" scoped>
</style>
<script>
import mui from "../../lib/mui/js/mui.min.js";
export default {
  props: ["max"],
  mounted() {
    mui(".mui-numbox").numbox();
  },
  methods: {
    postnum() {
      this.$emit("getCount", parseInt(this.$refs.numbox.value));
    }
  },
  watch: {
    max: function(newVal, oldVal) {
      mui(".mui-numbox")
        .numbox()
        .setOption("max", newVal);
    }
  }
};
</script>